home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / Assemblers / hecasm / asm6.c < prev    next >
C/C++ Source or Header  |  1995-07-26  |  5KB  |  158 lines

  1.  
  2. /* this contains all the global variable declarations and the */
  3. /* contents of the permanent symbol table */
  4.  
  5. #include "asm.h"
  6.  
  7. /* flags */
  8. int    lflag=0;        /* -l flag */
  9. int    nflag=0;        /* -n flag */
  10.  
  11. /* program directive variables */
  12. int    radix = DEC;        /* default radix */
  13.  
  14. /* position */
  15. int    pass=0;            /* Which pass? */
  16. int    lineno=0;        /* Line number */
  17.  
  18. /* text buffers */
  19. char    *sptr=0;        /* Source pointer */
  20. char    sbuf[SRCMAX];        /* Source buffer */
  21. int    *cptr=0;        /* Listing code pointer */
  22. int    cbuf[CLMAX];        /* Listing code buffer */
  23. char    *eptr=0;        /* Error pointer */
  24. char    ebuf[ERRMAX];        /* Error buffer */
  25. int    cadr;            /* address of object line */
  26. int    crec;            /* next object word */
  27. int    crbf[CBMAX];        /* object code buffer */
  28.  
  29.  
  30. int    refcnt=0;        /* Reference counter */
  31.  
  32. /* listing flags */
  33. int listmode;            /* listing mode for a line */
  34. int listaddr;            /* start address of a line */
  35.  
  36. /* line assembly */
  37. int    opcode;            /* instruction opcode */
  38.  
  39. /* file pointers */
  40. FILE    *ifp =    NULL;        /* input file pointer */
  41. FILE    *ofp =    NULL;        /* output file pointer */
  42. FILE    *lfp =    NULL;        /* listing file pointer */
  43.  
  44.  
  45. /*
  46.  * Reference table
  47.  */
  48. struct reflst reftab[REFMAX] = 
  49.     {
  50.     0,NULL 
  51.     };
  52.  
  53. /*
  54.  * User symbol table.
  55.  */
  56. struct    sym    ust[USERMAX];
  57.  
  58. /* pointer to the location counter in the ust */
  59. struct    sym    *dot;
  60.  
  61.  
  62. /*
  63.  * Opcode table.
  64.  * Also contains pseudo operations and
  65.  * registers.
  66.  */
  67. /* this table is search by a binary search therefore alphabetical */
  68. /* order must be maintained.  See asm.h for details of table contents */
  69. struct sym pst[] = {
  70.     ".byte",    GR_BYTE,    0,    NULL,    0,    1,
  71.     ".cc",        GR_CC,        0,    NULL,    7,    1,
  72.     ".cs",        GR_CC,        0,    NULL,    15,    1,
  73.     ".eq",        GR_CC,        0,    NULL,    13,    1,
  74.     ".equ",        GR_EQU,        0,    NULL,    0,    1,
  75.     ".f",        GR_CC,        0,    NULL,    3,    1,
  76.     ".ge",        GR_CC,        0,    NULL,    2,    1,
  77.     ".gt",        GR_CC,        0,    NULL,    12,    1,
  78.     ".hi",        GR_CC,        0,    NULL,    14,    1,
  79.     ".le",        GR_CC,        0,    NULL,    4,    1,
  80.     ".list",    GR_LIST,    0,    NULL,    0,    1,
  81.     ".ls",        GR_CC,        0,    NULL,    6,    1,
  82.     ".lt",        GR_CC,        0,    NULL,    10,    1,
  83.     ".mi",        GR_CC,        0,    NULL,    9,    1,
  84.     ".ne",        GR_CC,        0,    NULL,    5,    1,
  85.     ".org",        GR_ORG,        0,    NULL,    0,    1,
  86.     ".pascii",    GR_PASCII,    0,    NULL,    0,    1,
  87.     ".pl",        GR_CC,        0,    NULL,    1,    1,
  88.     ".radix",    GR_RADIX,    0,    NULL,    0,    1,
  89.     ".rmb",        GR_RMB,        0,    NULL,    0,    1,
  90.     ".rmw",        GR_RMW,        0,    NULL,    0,    1,
  91.     ".t",        GR_CC,        0,    NULL,    11,    1,
  92.     ".uascii",    GR_UASCII,    0,    NULL,    0,    1,
  93.     ".vc",        GR_CC,        0,    NULL,    0,    1,
  94.     ".vs",        GR_CC,        0,    NULL,    8,    1,
  95.     ".word",    GR_WORD,    0,    NULL,    0,    1,
  96.  
  97.     "add",        GR_FMT1,    0,    NULL,    0x0000,    1,
  98.     "addc",        GR_FMT1,    0,    NULL,    0x1000,    1,
  99.     "and",        GR_FMT1,    0,    NULL,    0x3000,    1,
  100.     "bra",        GR_FMT3,    0,    NULL,    0xc000,    1,
  101.     "btst",        GR_FMT1,    0,    NULL,    0xb000,    1,
  102.     "clc",        GR_FMT4,    0,    NULL,    0xf100,    1,
  103.     "cli",        GR_FMT4,    0,    NULL,    0xf300,    1,
  104.     "clr",        GR_FMT2,    0,    NULL,    0xc300,    1,
  105.     "cmp",        GR_FMT1,    0,    NULL,    0xa000,    1,
  106.     "dec",        GR_FMT2,    0,    NULL,    0x8300,    1,
  107.     "exch",        GR_FMT6,    0,    NULL,    0xf600,    1,
  108.     "inc",        GR_FMT2,    0,    NULL,    0x8200,    1,
  109.     "jsr",        GR_FMT3,    0,    NULL,    0xc100,    1,
  110.     "ldf",        GR_FMT2,    0,    NULL,    0xe200,    1,
  111.     "move",        GR_FMT8,    0,    NULL,    0xd000,    1,
  112.     "neg",        GR_FMT2,    0,    NULL,    0x8100,    1,
  113.     "not",        GR_FMT2,    0,    NULL,    0x8000,    1,
  114.     "or",        GR_FMT1,    0,    NULL,    0x5000,    1,
  115.     "pc",        GR_REG,        0,    NULL,    15,    1,
  116.     "push",        GR_FMT5,    0,    NULL,    0xe300,    1,
  117.     "r0",        GR_REG,        0,    NULL,    0,    1,
  118.     "r1",        GR_REG,        0,    NULL,    1,    1,
  119.     "r10",        GR_REG,        0,    NULL,    10,    1,
  120.     "r11",        GR_REG,        0,    NULL,    11,    1,
  121.     "r12",        GR_REG,        0,    NULL,    12,    1,
  122.     "r13",        GR_REG,        0,    NULL,    13,    1,
  123.     "r14",        GR_REG,        0,    NULL,    14,    1,
  124.     "r15",        GR_REG,        0,    NULL,    15,    1,
  125.     "r2",        GR_REG,        0,    NULL,    2,    1,
  126.     "r3",        GR_REG,        0,    NULL,    3,    1,
  127.     "r4",        GR_REG,        0,    NULL,    4,    1,
  128.     "r5",        GR_REG,        0,    NULL,    5,    1,
  129.     "r6",        GR_REG,        0,    NULL,    6,    1,
  130.     "r7",        GR_REG,        0,    NULL,    7,    1,
  131.     "r8",        GR_REG,        0,    NULL,    8,    1,
  132.     "r9",        GR_REG,        0,    NULL,    9,    1,
  133.     "rol",        GR_FMT2,    0,    NULL,    0x9100,    1,
  134.     "ror",        GR_FMT2,    0,    NULL,    0x9300,    1,
  135.     "rti",        GR_FMT4,    0,    NULL,    0xf400,    1,
  136.     "rts",        GR_FMT4,    0,    NULL,    0xd8ef,    1,
  137.     "sec",        GR_FMT4,    0,    NULL,    0xf000,    1,
  138.     "sei",        GR_FMT4,    0,    NULL,    0xf200,    1,
  139.     "shl",        GR_FMT2,    0,    NULL,    0x9000,    1,
  140.     "shr",        GR_FMT2,    0,    NULL,    0x9200,    1,
  141.     "sp",        GR_REG,        0,    NULL,    14,    1,
  142.     "srch",        GR_FMT7,    0,    NULL,    0xf700,    1,
  143.     "stf",        GR_FMT2,    0,    NULL,    0xe100,    1,
  144.     "stop",        GR_FMT4,    0,    NULL,    0x7000,    1,
  145.     "sub",        GR_FMT1,    0,    NULL,    0x2000,    1,
  146.     "subc",        GR_FMT1,    0,    NULL,    0x4000,    1,
  147.     "swap",        GR_FMT2,    0,    NULL,    0xc200,    1,
  148.     "swi",        GR_FMT4,    0,    NULL,    0xf500,    1,
  149.     "test",        GR_FMT2,    0,    NULL,    0xe000,    1,
  150.     "xor",        GR_FMT1,    0,    NULL,    0x6000,    1,
  151. };    
  152.  
  153. /* calculate the size of the permantent symbol table */
  154. int pstsize = sizeof(pst)/sizeof(pst[0]);
  155.  
  156. /* this is a pointer to the end of the reference table */
  157. struct reflst *refptr = &reftab[0];    /* Pointer to end of reference table */
  158.